
import collections
import random

#生成一组10个以内的随机数
list=[random.randrange(5,8) for i in range(10)]
print("随机产生的列表：",list)
list2=[]

#词频统计
frequency = collections.Counter(list)

#比较词频是否大于N/2
def compare(frequency):
    for key,value in frequency.items():
        if value>len(list)/2:
            list2.append(key)
    if list2==[]:
        print("没有重复次数大于N/2的数，再试试吧~")
    else:
        print("重复次数超过N/2的数有：",end=' ')
        for x in list2:
            print(x,end=' ')


compare(frequency)